import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'logTitle',
    width: 100,
  },
  {
    title: '内容',
    dataIndex: 'logBody',
    width: 180,
    align: 'center',
  },
  {
    title: '金额',
    dataIndex: 'amount',
    width: 100,
    align: 'center',
  },
  {
    title: '支付状态',
    dataIndex: 'isRealPay',
    width: 100,
    align: 'center',
    customRender: ({ record }: Recordable) => {
      const isRealPayArray = [
        { label: '已支付', value: 1 },
        { label: '未支付', value: 2 },
      ];
      const isRealPay: any = isRealPayArray.find((item) => item.value == record.isRealPay);
      if (isRealPay) {
        return isRealPay.label;
      }
      return '';
    },
  },
  {
    title: '操作类型',
    dataIndex: 'optType',
    width: 100,
    align: 'center',
    customRender: ({ record }: Recordable) => {
      const optTypeArray = [
        { label: '增加', value: 1 },
        { label: '减少', value: 2 },
      ];
      const optType: any = optTypeArray.find((item) => item.value == record.optType);
      if (optType) {
        return optType.label;
      }
      return '';
    },
  },
  {
    title: '日志类型',
    dataIndex: 'logType',
    width: 100,
    align: 'center',
    customRender: ({ record }: Recordable) => {
      const logTypeArray = [
        { label: '充值', value: 1 },
        { label: '消费', value: 2 },
        { label: '退回', value: 3 },
      ];
      const logType: any = logTypeArray.find((item) => item.value == record.logType);
      if (logType) {
        return logType.label;
      }
      return '';
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
    align: 'center',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];
